package cn.czu.wyw.service.impl;

import cn.czu.wyw.mapper.UsersMapper;
import cn.czu.wyw.pojo.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName ServiceA
 * @Description
 * @Author wyw
 * @Date 2022/9/13 15:03
 * @Version 1.0
 */
@Service
public class ServiceA {

    @Autowired
    UsersMapper usersMapper;

    //@Transactional(rollbackFor = Exception.class)
    public void insertUser(Users user) throws Exception {
        for (int i = 0; i < 5; i++) {
            try {
                // usersMapper.insert(user);
                user.setUsername("wyw");
                user.setNickname("wyw");
                user.setPassword("123");
                for (int j = 0; j < 5; j++) {
                    test1();
                }
            }catch (Exception e){
                throw new Exception();
            }
            System.out.println("循环内");
        }
        System.out.println("循环外");

    }

    public void test1() throws Exception {
        int i = 10;
        if (i == 5){
            throw new RuntimeException();
        }
        try {
            int j = i/1;
        }catch (Exception e){
            throw new Exception();
        }
    }
}
